-
Notifications
You must be signed in to change notification settings - Fork 17
Feat: Add ExtraFields support to OpenAI providers for custom parameters #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rs (#1) Adds support for arbitrary extra fields in OpenAI and OpenAI-compatible providers to enable custom parameters required by OpenAI-compatible APIs like Z.AI GLM. The OpenAI Go SDK's ChatCompletionNewParams provides a SetExtraFields() method, but Fantasy had no way to utilize it. This change adds an ExtraFields field to ProviderOptions and calls SetExtraFields() when extra fields are present. Use case: Custom OpenAI-compatible APIs (like Z.AI GLM) require additional parameters such as thinking mode configuration that aren't part of OpenAI's API spec: ```json { "extra_fields": { "thinking": { "budget_tokens": 26214, "type": "enabled" } } } ``` Changes: - Add \`ExtraFields map[string]any\` field to ProviderOptions in both openai and openaicompat providers - Call \`params.SetExtraFields()\` in PrepareCallFunc when ExtraFields present - Minimal, non-breaking change using omitempty JSON tag This enables Crush (charmbracelet/crush#1171) and other Fantasy consumers to pass custom parameters to OpenAI-compatible APIs without modifying Fantasy for each specific API's custom fields. Tested: Build successful, no breaking changes to existing functionality. Co-authored-by: OutBot CI <[email protected]>
|
Hey @Jesssullivan I think I already have it setup to work as expected in crush charmbracelet/crush@6bb85dc#diff-53bdf62a2aac11b071b4d3138352d3e902a49cf41c52ed86bf68d39177a86ebdR529 I just pushed a commit today. |
Rad! thanks. I think these are complimentary additions actually, though I may be wrong (still wending around the Fantasy layer). In charmbracelet/crush@6bb85dc#diff-53bdf62a2aac11b071b4d3138352d3e902a49cf41c52ed86bf68d39177a86ebdR529, openaisdk.WithJSONSet() can inject JSON fields directly into SDK requests. This would mean these injections occur on provider creation, not per call. In this PR, we're adding a discreet ExtraFields mechanism, which works per-call rather than just at provider creation. |
…s file if it does not already exist
Configure GitLab CI for Fantasy SDK institutional fork with RenovateBot and private module access. ## Changes ### .gitlab-ci.yml (NEW) - Add sync job for upstream charmbracelet/fantasy main branch - Add RenovateBot job for dependency automation - Add build and test jobs with private module support - Configure Go 1.24 build environment ### .gitlab/ci/go-private-modules.yml (NEW) - Configure GOPRIVATE, GONOSUMDB, GONOPROXY for gitlab.com/tinyland/* - Set up Git authentication with CI_JOB_TOKEN - Create .netrc for Go module downloads - Provide reusable .go_private_modules_setup mixin ### .gitlab/renovate.json (NEW) - Track OpenAI, Anthropic, AWS, GCP provider SDKs - Group Charmbracelet ecosystem updates - Configure automated dependency dashboard - Set review requirements for major updates ## Integration This complements the RenovateBot K8s deployment and enables Fantasy SDK to be consumed as a private module by downstream projects (Crush, etc.) within the tinyland namespace. 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
feat: Add full Fantasy SDK with CI/CD See merge request tinyland/ai/fuzzy-fantasy!2
The validate stage does not exist, causing all pipelines to fail. Changed go-mod-verify job to use the test stage instead. This fixes all failing CI runs. 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
go.mod requires Go 1.24.5 but go-private-modules.yml had hardcoded 1.23. Updated all golang:1.23 images → golang:1.24 to match go.mod requirement. 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
fix(deps): update module github.com/openai/openai-go/v2 to v3.6.1 See merge request tinyland/ai/fuzzy-fantasy!6
fix(deps): update charmbracelet packages See merge request tinyland/ai/fuzzy-fantasy!3
fix(deps): update gopkg.in/dnaeon/go-vcr.v4 digest to 3f65415 See merge request tinyland/ai/fuzzy-fantasy!4
fix(deps): update module github.com/aws/aws-sdk-go-v2 to v1.39.4 See merge request tinyland/ai/fuzzy-fantasy!5
…dule path - Updates github.com/charmbracelet/anthropic-sdk-go to newer pseudo-version - Removes replace directive for anthropic-sdk-go (no longer needed) - Keeps replace directive for go-genai pointing to google.golang.org/genai - Fixes CI build failures caused by module path mismatches
Merges upstream/main to incorporate bedrock-related fixes: - fix(bedrock): update anthropic sdk with fix for bedrock auth (e058884) - fix(bedrock): prefix model id with region automatically (ed9a9b8) - Release v0.1.1 (5260f37) Dependencies updated to upstream versions: - anthropic-sdk-go: v0.0.0-20251024181547 - go-genai: v0.0.0-20251021165952 - x/exp/slice: v0.0.0-b4e2667e5ad5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Adds auto-merge configuration for non-breaking dependency updates: - Digest updates: auto-merge when CI passes - Minor updates: auto-merge when CI passes - Patch updates: auto-merge when CI passes - Major updates: continue to require manual review This reduces manual overhead while maintaining safety for breaking changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
chore: sync upstream fantasy bedrock fixes See merge request tinyland/ai/fuzzy-fantasy!9
fix(deps): update module github.com/openai/openai-go/v2 to v3.6.1 See merge request tinyland/ai/fuzzy-fantasy!7
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to f594ac0 See merge request tinyland/ai/fuzzy-fantasy!12
fix(deps): update module github.com/openai/openai-go/v2 to v3.7.0 See merge request tinyland/ai/fuzzy-fantasy!10
… 'main' fix(deps): update github.com/charmbracelet/go-genai digest to a075d35 See merge request tinyland/ai/fuzzy-fantasy!11
Fixes CI build failures caused by module path mismatch. Previously required github.com/charmbracelet/go-genai with a replace directive, but the actual module declares itself as google.golang.org/genai. Changes: - Update go.mod to directly require google.golang.org/genai v1.32.0 - Remove replace directive for charmbracelet fork - Update import in providers/google/google.go This unblocks 3 pending Renovate MRs (charmbracelet#13, charmbracelet#11, charmbracelet#10) and fixes main branch CI pipeline failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
fix(deps): update module github.com/aws/aws-sdk-go-v2 to v1.39.5 See merge request tinyland/ai/fuzzy-fantasy!16
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to 681bf55 See merge request tinyland/ai/fuzzy-fantasy!17
fix(deps): update gopkg.in/dnaeon/go-vcr.v4 digest to 3f65415 See merge request tinyland/ai/fuzzy-fantasy!15
This PR adds
ExtraFieldssupport to Fantasy'sopenaiandopenaicompatproviders, enabling custom parameters for OpenAI-compatible APIs that require fields beyond the standard OpenAI specification.Changes
Added
ExtraFields map[string]anytoProviderOptionsin both providers:providers/openai/provider_options.goproviders/openaicompat/provider_options.goThe extra fields are applied via
params.SetExtraFields()in the respective hook functions:providers/openai/language_model_hooks.goproviders/openaicompat/language_model_hooks.goUse Case: Z.AI GLM Thinking Mode
This enables passing custom parameters like Z.AI GLM's thinking mode configuration:
The extra fields are passed through to the OpenAI SDK's
SetExtraFields()method and included in the HTTP request to the provider API.Dependencies
Depends on: #41 (ZAI provider support)
Related
Relates to: charmbracelet/crush#1295 - Integration in Crush
CONTRIBUTING.md.